﻿using WholesaleOnline.Controller.Request;
using WholesaleOnline.Controller.Routing;
using WholesaleOnline.Controller.Storage;

namespace WholesaleOnline.Controller.Handlers
{
    public abstract class RequestHandler
    {
        private RequestHandler m_NextHandler = null;
        protected RequestHandler NextHandler { get { return m_NextHandler; } }

        private Route m_Route = null;
        protected Route Route { get { return m_Route; } }

        private IHttpStorage m_Storage;
        protected IHttpStorage Storage { get { return m_Storage; } }

        private RequestHandler() { }

        public RequestHandler(IHttpStorage storage)
        {
            m_Storage = storage;
        }

        public RequestHandler(string route, IHttpStorage storage)
            : this(storage)
        {
            m_Route = new Route(route);

        }

        public RequestHandler SetNextHandler(RequestHandler requestHandler)
        {
            m_NextHandler = requestHandler;
            return m_NextHandler;
        }

        public abstract void Handle(WebRequest webRequest);
    }
}
